package General;

import Files.Configuration;
import GUI.Dialogs.ObserverDialog;
import GUI.Dialogs.SplashDialog;
import GUI.Editor_MainGUI.EditorWindow;
import other.Wizard;
import java.awt.Color;
import java.io.File;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

/**
 *
 * @author David
 */
public class Start
{

    private static File configurationFile = new File("dat//config.cfg");

    public static void main(String[] args)
    {
        CurrentData.setObserverDialog(new ObserverDialog());
        if (configurationFile.exists())
        {
            CurrentData.setConfiguration((Configuration) Wizard.loadFile(configurationFile.getAbsolutePath()));
        } else
        {
            CurrentData.setConfiguration(new Configuration());
            Wizard.saveFile(configurationFile.getAbsolutePath(), CurrentData.getConfiguration());
        }
        CurrentData.huntMaterials();
        CurrentData.setSplashDialog(new SplashDialog());
        de.muntjak.tinylookandfeel.Theme.loadTheme(new File("dat//dark.theme"));
        try
        {
            UIManager.setLookAndFeel("de.muntjak.tinylookandfeel.TinyLookAndFeel");
            UIManager.getDefaults().put("TaskPane.titleBackgroundGradientStart", Color.gray);
            UIManager.getDefaults().put("TaskPane.titleBackgroundGradientEnd", Color.lightGray);
        } catch (ClassNotFoundException ex)
        {
            CurrentData.getObserverDialog().printError("Failed to modify LookAndFeel", ex);
        } catch (InstantiationException ex)
        {
            CurrentData.getObserverDialog().printError("Failed to modify LookAndFeel", ex);
        } catch (IllegalAccessException ex)
        {
            CurrentData.getObserverDialog().printError("Failed to modify LookAndFeel", ex);
        } catch (UnsupportedLookAndFeelException ex)
        {
            CurrentData.getObserverDialog().printError("Failed to modify LookAndFeel", ex);
        }

        SwingUtilities.invokeLater(new Runnable()
        {
            public void run()
            {
                new EditorWindow();
            }
        });
    }
}
